package org.xiaojinlong.reading;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
 * @author Jin Long
 * 2015/3/11.
 */

class Holder<T> {
    private T a;
    public Holder(T a) {
        this.a = a;
    }

    public void set(T a) {
        this.a = a;
    }

    public T get() {
        return a;
    }
}

class Stack<T> {
    private class Node {
        T value;
        Node next;
        Node() { value = null; next = null; }
        Node(T x, Node next) {
            value = x;
            this.next = next;
        }
        boolean empty() { return value == null && next == null; }
    }

    Node top = new Node();

    public T pop() {
        T result = top.value;
        if (!top.empty())
            top = top.next;
        return result;
    }

    public void push(T t) {
        top = new Node(t, top);
    }
}

public class Generics {
    public static void main(String[] args) {
        Holder<String> h = new Holder<>("Holder");
        Stack<String> stack = new Stack<>();
        stack.push("hello");
        stack.push("wow");
        System.out.println(stack.pop());
        List<? extends List<? extends A>> ss = new ArrayList<List<B>>();
        HashMap<String, Integer> map;
    }
}

class A {}

class B extends A {}
